/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.designPatterns.composity;
import java.util.ArrayList;
import java.util.List;
/**
 *
 * @author minga
 */
public class Composity implements Component{
    List<Component> components = new ArrayList<Component>();

    public List<Component> getComponents() {
        return components;
    }

    public Component getComponents(int index) {
        return components.get(index);
    }
    
    @Override
    public void SayHello() {
       for(Component component:components)
       {
          component.SayHello(); 
       }
    }

    @Override
    public void SayGooBay() {
       for(Component component:components)
       {
          component.SayGooBay(); 
       }
    }
    public void add(Component component)
    {
        components.add(component);
    }
    public void remove(Component component)
    {
        components.remove(component);
    }
}
